import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vite.dev/config/
export default defineConfig({
  base: '/h5/',
  plugins: [vue()],
  optimizeDeps: {
    esbuildOptions: {
      target: 'es2015'
    }
  },
  build: {
    target: 'es2015',
    outDir: 'dist/h5',
    chunkSizeWarningLimit: 1000,
    rollupOptions: {
      output: {
        manualChunks: {
          'vue-vendor': ['vue', 'vue-router'],
          'vant': ['vant'],
          'axios': ['axios']
        }
      }
    }
  },
  server: {
    port: 3000,
    open: true,
    // 配置代理服务器解决CORS问题
    proxy: {
      '/api': {
        target: 'http://jiu.test.com/api/',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  }
})
